#include <stdlib.h>

//thomas wang's 32 bit mix function
unsigned int dictIntHashFunction(unsigned int key)
{
	key += ~(key << 15);
	key ^=  (key >> 10);
	key +=  (key << 3);
	key ^=  (key >> 6);
	key += ~(key << 11);
	key ^=  (key >> 16);
	return key;
}


unsigned int dictGenHashFunction(const unsigned char * buf, int len)
{
	unsigned int hash = 5381;
	while(len--)
		hash = ((hash << 5) + hash) + (*buf++);
	return hash;
}

unsigned int dictGenCaseHashFunction(const unsigned char * buf, int len)
{
	unsigned int hash = 5381;
	while(len--)
		hash = ((hash << 5) + hash) + tolower((*buf++));
	return hash;
}
